package com.wishu.houses.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.interfaces.MPJBaseJoin;
import com.wishu.houses.domain.TbPremisesInfo;
import com.wishu.houses.service.TbPremisesInfoService;
import com.wishu.houses.mapper.TbPremisesInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author liu'wen
 * @description 针对表【tb_premises_info(楼盘信息表)】的数据库操作Service实现
 * @createDate 2023-04-21 15:22:57
 */
@Service
public class TbPremisesInfoServiceImpl extends ServiceImpl<TbPremisesInfoMapper, TbPremisesInfo>
        implements TbPremisesInfoService {
    @Resource
    TbPremisesInfoMapper tbPremisesInfoMapper;

    /**
     * 列表 + 分页 + 名称模糊查询 + 省市县条件查询
     * @param page 分页
     * @param tbPremisesInfo 实体类对象
     * @return
     */
    @Override
    public IPage<TbPremisesInfo> selectpage(Page page, TbPremisesInfo tbPremisesInfo) {
        LambdaQueryWrapper<TbPremisesInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(ObjectUtils.isNotEmpty(tbPremisesInfo.getName()),TbPremisesInfo::getName,tbPremisesInfo.getName());
        wrapper.eq(ObjectUtils.isNotNull(tbPremisesInfo.getProvince()),TbPremisesInfo::getProvince,tbPremisesInfo.getProvince());
        wrapper.eq(ObjectUtils.isNotNull(tbPremisesInfo.getCity()),TbPremisesInfo::getCity,tbPremisesInfo.getCity());
        wrapper.eq(ObjectUtils.isNotNull(tbPremisesInfo.getCounty()),TbPremisesInfo::getCounty,tbPremisesInfo.getCounty());
        wrapper.eq(ObjectUtils.isNotNull(tbPremisesInfo.getPremisesType()),TbPremisesInfo::getPremisesType,tbPremisesInfo.getPremisesType());
        return tbPremisesInfoMapper.selectPage(page,wrapper);
    }

}




